package lock;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.kkom1.tapeat.MainActivity;

import data_management.KeyguardData;
import data_management.SettingData;

public class LockscreenReceiver extends BroadcastReceiver {
	public LockscreenReceiver() {
	}

	@Override
	public void onReceive(Context context, Intent intent) {

		if (intent.getAction().equals("android.intent.action.SCREEN_OFF")) {
			// if (KeyguardData.km.isKeyguardLocked()) {
			KeyguardData.keylock.reenableKeyguard();

			context.startActivity(new Intent(context, MainActivity.class)
					.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
			// }
			return;
		}

		if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
			KeyguardData.keylock.reenableKeyguard();

			if (SettingData.getInstance().isLock_on())
				context.startService(new Intent(
						"com.kkom1.tapeat.services.lockservice"));
			return;
		}

		throw new UnsupportedOperationException("Not yet implemented");
	}
}
